package com.fenghongzhang.day009test;

import androidx.appcompat.app.AppCompatActivity;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        MySqlHelp mySqlHelp = new MySqlHelp(this, "food.db", null, 1);
        SQLiteDatabase readableDatabase = mySqlHelp.getReadableDatabase();

        Cursor apple = readableDatabase.query("apple", null, null, null, null, null, null);
        if(apple != null){
            while (apple.moveToNext()){
                String name = apple.getString(apple.getColumnIndex("name"));
                Toast.makeText(this, name, Toast.LENGTH_SHORT).show();
            }
            apple.close();
        }
    }
}
